package structure;

public class branch02 {
    public static void main(String[] args) {
//        for循环
        //打印5行Hello World
        //看for()里的条件，条件成立打印出{}里的内容，条件不成立则终止运行
        for(int i = 0; i < 5; i++){
            System.out.println("Hello World");
        }
        for(int i = 1; i <= 10; i += 2){
            System.out.println("你好");
        }

        //for循环批量产生数据
        //输出1-100
        for (int i = 1; i <= 100; i++) {
            System.out.println(i);
        }

        //求1-100的和
        int sum = 0;
        for (int i = 1; i <= 100; i++) {
            sum += i;
        }
        System.out.println(sum);

        //求1-100以内偶数和
        int sum1 = 0;
        for (int i = 0; i <= 100; i += 2) {
            sum1 += i;
        }
        System.out.println(sum1);

        //for+if求100以内偶数和
        int sum2 = 0;
        for (int i = 0; i <= 100; i++) {
            if(i % 2 == 0){
                sum2 = sum2 + i;
            }
        }
        System.out.println(sum2);
    }
}
